package com.darren.euc.dao.impl;


import java.math.BigInteger;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.darren.euc.dao.MessageVisitDao;
import com.darren.euc.entity.MessageVisit;


@Repository
public class MessageVisitDaoImpl extends BaseDaoImpl<MessageVisit, Integer> implements MessageVisitDao {
	
	@Override
	public BigInteger getUnreadCount(Integer userId){
		Session session = sessionFactory.getCurrentSession();	
		Query query  = session.createSQLQuery(" select count(1) from euc_message_visit where message_status = 0 and user_id = ? ; ");
		query.setParameter(0, userId);
		BigInteger count = (BigInteger) query.uniqueResult();
		return  count;
	}
	
}